<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<div th:fragment="editor">
    <link rel="stylesheet" th:href="@{/editor/css/editormd.min.css}"/>
    <div id="editor" th:fragment="markdown-editor">
        <!-- Tips: Editor.md can auto append a `<textarea>` tag -->
        <!--修改或新增-->
        <textarea class="form-control" th:id="content" name="content" rows="16" style="display:none;"
                  th:if="${article!=null}" th:text="${article.getContent()}"></textarea>
        <textarea class="form-control" th:id="content" name="content" rows="16" style="display:none;"
                  th:if="${article==null}"></textarea>
    </div>
    <script th:src="@{/js/jquery-3.5.1.js}"></script>
    <script th:src="@{/editor/editormd.min.js}"></script>
    <script type="text/javascript" th:inline="javascript">
        $(function () {
            let imageUploadURLPrefix = window.location.protocol + "//" + window.location.host;
            let editor = editormd("editor", {
                width: "100%",
                height: 720,
                toc: true,
                saveHTMLToTextarea: true,
                imageUpload: true,
                imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                imageUploadURL: imageUploadURLPrefix + '/upload/image',
                path: "/editor/lib/"  // Autoload modules mode, codemirror, marked... dependents libs path
            });
        });
    </script>
</div>
</html>